﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Controls_proty : System.Web.UI.UserControl
{
    string SQL;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            pro_sm();
        }
    }
    public void pro_sm()
    {
        SQL = "select * from Class where Menu_Level=2";
        DataTable dt = Class1.ExecSel(SQL);
        dl_sj.DataSource = dt;
        dl_sj.DataKeyField = "Menu_ID";
        dl_sj.DataBind();
        //string aa = dt.Rows[0]["Menu_ID"].ToString();

        SqlConnection con = Class1.DBconnection();
        string sqlStr = "select p_z_ID from Product ";
        SqlDataAdapter da = new SqlDataAdapter(sqlStr, con);
        DataSet ds = new DataSet();
        da.Fill(ds, "p_z_ID");
        string num = ds.Tables["p_z_ID"].Rows.Count.ToString();
        e_Count.Text = num;
        da.Dispose();
        ds.Dispose();
        con.Close();
        con.Dispose();
    }
    protected void dl_sj_DataBinding(object sender, DataListItemEventArgs e)
    {
        Label Label1 = (Label)e.Item.FindControl("s_Count");
        SqlConnection con = Class1.DBconnection();
        string sqlStr = "select p_s_ID from Product where p_s_ID=" + this.dl_sj.DataKeys[e.Item.ItemIndex].ToString() + "";
        SqlDataAdapter da = new SqlDataAdapter(sqlStr, con);
        DataSet ds = new DataSet();
        da.Fill(ds, "p_s_ID");
        string num = ds.Tables["p_s_ID"].Rows.Count.ToString();
        Label1.Text = num;
        da.Dispose();
        ds.Dispose();
        con.Close();
        con.Dispose();
    }
}
